<template>
  <body id="login-page">
  <el-form
      class="login-container"
      label-position="left"
      label-width="0px"
  >
    <h3 class="login_title">系统登录
<!--      <el-button @click="toRegister()">点我注册</el-button>-->
    </h3>
    <el-form-item>
      <el-input
          type="text"
          v-model="loginForm.no"
          auto-complete="off"
          placeholder="账号"
      ></el-input>
    </el-form-item>
    <el-form-item>
      <el-select v-model="loginForm.roleId" placeholder="请选择活动区域">
        <el-option label="超级管理员" value="0"></el-option>
        <el-option label="管理员" value="1"></el-option>
        <el-option label="普通账号" value="2"></el-option>
      </el-select>
    </el-form-item>
    <el-form-item>
      <el-input
          type="password"
          v-model="loginForm.password"
          auto-complete="off"
          placeholder="密码"
          @keyup.enter.native="Login()"
      ></el-input>
    </el-form-item>
    <el-form-item style="width: 100%">
      <el-button
          type="primary"
          style="width: 100%;  border: none"
          @click="Login()"
      >登录</el-button
      >
    </el-form-item>
  </el-form>
  </body>
</template>

<script>
export default {
  name: "Login",
  data() {
    return {
      loginForm: {
        no: "",
        password: "",
        roleId:''
      },
    };
  },
  methods: {
    Login(){
      console.log('submit',this.loginForm);

      this.axios.post(this.$httpUrl+'/user/login',this.loginForm).then(
          (res) =>{
            console.log(res);
            let well=res.data.content.loginResp;
            //处理缓存
            if(well != null){
              //存储
              sessionStorage.setItem("CurUser",JSON.stringify(well));
              console.log(res.data.content.menu);
              this.$store.commit("setMenu",res.data.content.menu);
              this.loginForm={};
              this.$message({
                message: '成功登录,欢迎来到后台管理系统',
                type: 'success'
              });
              this.$router.push({path:'/Index'})
            }else {
              this.loginForm={}
              this.$message({
                message: '请输入正确的登录信息',
                type: 'error'
              });
            }
          })
    },


    // toRegister(){
    //   this.$router.push({path:'/Register'})
    // }
  },
};
</script>

<style scoped>
#login-page {
  background: url("../assets/01.jpg") no-repeat;
  background-position: center;
  height: 100%;
  width: 100%;
  background-size: cover;
  position: fixed;
}
body {
  margin: 0px;
}
.login-container {
  border-radius: 15px;
  background-clip: padding-box;
  margin: 90px auto;
  width: 350px;
  padding: 35px 35px 15px 35px;
  background: #fff;
  border: 1px solid #eaeaea;
  box-shadow: 0 0 25px #cac6c6;
}

.login_title {
  margin: 0px auto 40px auto;
  text-align: center;
  color: #505458;
}
</style>
